public class BankAccount {
    private String accountNumber; // 账户号码
    private String accountHolderName; // 账户持有人姓名
    private double balance; // 账户余额，默认为0

    // 构造方法
    public BankAccount(String accountNumber, String accountHolderName, double initialBalance) {
        if (isValidAccountNumber(accountNumber) && initialBalance >= 0) {
            this.accountNumber = accountNumber;
            this.accountHolderName = accountHolderName;
            this.balance = initialBalance;
        } else {
            System.out.println("Invalid account number or initial balance.");
        }
    }

    // 存款方法
    public void deposit(double amount) {
        if (amount > 0) {
            balance += amount;
            System.out.println("存了"+ amount+"元");
        } else {
            System.out.println("存款失败");
        }
    }

    // 取款方法
    public void withdraw(double amount) {
        if (amount > 0 && amount <= balance) {
            balance -= amount;
            System.out.println("取了"+ amount+"元");
        } else {
            System.out.println("取款失败");
        }
    }

    // 获取余额
    public double getBalance() {
        return balance;
    }

    // 判断是否透支
    public boolean isOverdrawn() {
        return balance <= 0;
    }

    // 判断是否为 VIP 账户
    public void isVIP() {
        if (balance > 100000) {
            System.out.println("该账户为VIP账户");
        } else {
            System.out.println("该账户为普通账户");
        }
    }

    // 验证账号是否合法
    private boolean isValidAccountNumber(String accountNumber) {
        return accountNumber.matches("\\d{8,}"); // 正则表达式匹配至少8位的纯数字
    }
}